<template>
  <div class="relogin">
    <div class="body">
      <div class="phone">
        <p>手机号</p>
        <input type="text" placeholder="请输入手机号" v-model="relogin.phoneNumber">
      </div>
      <div class="password">
        <p>密码</p>
        <input type="password" placeholder="请输入密码" v-model="relogin.password">
      </div>
      <div class="button">
        <button @click="turnRegister">登录</button>
      </div>
    </div>
  </div>
</template>

<script>
  export default {
    name: "relogin",
    data() {
      return {
        relogin: {
          phoneNumber: '',
          password: ''
        },
      }
    },
    methods: {
      turnRegister() {
        this.$cookies.set('token', 'ss');//发送token值，token=ss
        this.$router.push('/register');
      }

    },

    created() {

      let token = this.$cookies.get('token');//接收token的值
      if (token) {//token的值不等于空时(token!=="")
        this.$router.push('/register');
        // this.$axios({
        //   url: "/login",
        //   methods: "post",
        //   params: {
        //     token: token
        //   }
        // }).then(async data => {
        //
        //   _this.$cookies.set('token', data.token, 60 * 60 * 24)
        // }).catch(error =>{
        //   _this.$cookies.set('token',null)
        //   console.log(error.msg)
        // })

      } else {
        console.log("000")
      }
    }
  }
</script>

<style scoped>
  .body {
    box-sizing: border-box;
    position: absolute;
    top: 205px;
    left: 50%;
    transform: translateX(-50%);
    width: 430px;
    height: 480px;
    /*background-color: red;*/
    border-radius: 8px;
    box-shadow: 0px 0px 10px 1px rgba(240, 240, 240, 1);
    border: 1px solid rgba(240, 240, 240, 1);
  }

  .phone {
    width: 350px;
    margin: 50px 0 0 40px;
  }

  .phone p {
    color: rgba(141, 141, 141, 1);
    font-size: 14px;
    font-family: SourceHanSansSC-regular;
  }

  .phone input {
    box-sizing: border-box;
    outline: none;
    width: 100%;
    height: 50px;
    background: rgba(249, 249, 249, 1);
    border-radius: 4px;
    border: 1px solid rgb(230, 230, 230);
    padding-left: 8px;
    color: #333;
  }

  .password {
    width: 350px;
    margin: 18px 0 0 40px;
  }

  .password p {
    color: rgba(141, 141, 141, 1);
    font-size: 14px;
    font-family: SourceHanSansSC-regular;
  }

  .password input {
    box-sizing: border-box;
    outline: none;
    width: 100%;
    height: 50px;
    background: rgba(249, 249, 249, 1);
    border-radius: 4px;
    border: 1px solid rgb(230, 230, 230);
    padding-left: 8px;
    color: #333;
  }

  .button {
    width: 350px;
    height: 50px;
    margin: 20px 0 0 40px;
  }

  .button button {
    width: 350px;
    height: 50px;
    line-height: 20px;
    border-radius: 4px;
    background-color: rgba(22, 174, 156, 1);
    color: rgba(16, 16, 16, 1);
    font-size: 14px;
    text-align: center;
    box-shadow: 0px 0px 10px 1px rgba(22, 174, 156, 0.5);
    font-family: Roboto;
  }

</style>
